package com.city.repository.report;

import com.city.domain.auth.format.CtBranchFormat;
import com.city.domain.report.CtBranch;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CtBranchRepository extends JpaRepository<CtBranch,Integer> {

    @Query(value =  "SELECT * FROM ct_branch " +
                    "WHERE parent = ?1", nativeQuery = true)
    List<CtBranch> findAllByParent(Integer parent);

    List<CtBranch> findAll();


    @Query(value = "SELECT * FROM ct_branch limit ?1,?2",nativeQuery = true)
    List<CtBranch> findByPageAndLimit(Integer page,Integer limit);

    @Query(value = "SELECT * FROM ct_branch where id = ?1",nativeQuery = true)
    CtBranch findById(Integer id);
}
